<?php
/**
 * Featured Item snippet
 *
 * @param string $url      - The place the hyperlink should go
 * @param bool   $external - TRUE will add target="_blank" to the anchor tag (default FALSE)
 * @param string $img      - The link to where the image lives
 * @param string $title    - The text that sits below the image as it's title
 * @param string $subtitle - Usually a date, but the subtitle for the item
 */
 $title = isset($title) ? $title : false;
 $imgAlt = $title ?: ( isset($subtitle) ? $subtitle : '' );
?>

<li>
    <?php if($url) : ?>
    <a href="<?= $url ?>"<?= isset($external) && $external ? ' target="_blank"' : '' ?>>
        <img src="<?= $img ?>" alt="<?= $imgAlt ?>" title="<?= $imgAlt ?>" width="360" height="203">
    </a>
    <a href="<?= $url ?>">
        <p><?= $title ?: '' ?><?php if(isset($subtitle)): ?><time><?= $subtitle ?></time><?php endif ?></p>
    </a>
    <?php else: ?>
    <img src="<?= $img ?>" alt="<?= $title ?>" title="<?= $title ?>" width="360" height="203">
    <p><?= $title ?><?php if(isset($subtitle)): ?><time><?= $subtitle ?></time><?php endif ?></p>
    <?php endif ?>
</li>
